package cn.com.yusys.yusp.admin.service;

import cn.com.yusys.yusp.admin.repository.mapper.CustomerViewInfoMapper;
import cn.com.yusys.yusp.commons.dto.Obj;
import cn.com.yusys.yusp.commons.mapper.CommonMapper;
import cn.com.yusys.yusp.commons.mapper.QueryModel;
import cn.com.yusys.yusp.commons.service.CommonService;
import com.github.pagehelper.PageHelper;
import io.swagger.models.Model;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import sun.applet.resources.MsgAppletViewer;

import javax.annotation.Resource;
import javax.management.Query;
import java.util.List;
import java.util.Map;

/**
 * @author zhoukanghui
 * @version 1.0
 * @date 2021/7/14 16:36
 */
@Service
public class CustomerViewInfoService extends CommonService {

    private static Logger logger = LoggerFactory.getLogger(CustomerViewInfoService.class);

    @Resource
    private CustomerViewInfoMapper custViewMapper;

    @Override
    protected CommonMapper getMapper() {
        return null;
    }

    /**
     * 根据客户号查询客户视图中客户基本信息
     * @param model
     * @return
     */
    public List<Map<String, Object>> getCustInfomation(QueryModel model) {
        return custViewMapper.getCustInfomation(model);
    }

    /**
     * 时间轴(开户、签约、产品、动账、沟通记录)
     * @param model
     * @return
     */
    public List<Map<String, Object>> getTimeAxsInfomation(QueryModel model){
        return custViewMapper.getTimeAxsInfomation(model);
    }

    /**
     * 存款明细
     * @param model
     * @return
     */
    public List<Map<String, Object>> getCustDepInfo(QueryModel model){
        PageHelper.startPage(model.getPage(), model.getSize());
        List<Map<String, Object>> depInfoList = null;
        depInfoList = custViewMapper.getCustDepInfo(model);
        PageHelper.clearPage();
        return depInfoList;
    }

    /**
     * 贷款明细
     * @param model
     * @return
     */
    public List<Map<String, Object>> getCustLoanInfo(QueryModel model){
        PageHelper.startPage(model.getPage(), model.getSize());
        List<Map<String, Object>> loanInfoList = null;
        loanInfoList = custViewMapper.getCustLoanInfo(model);
        PageHelper.clearPage();
        return loanInfoList;
    }

    /**
     * 理财明细
     * @param model
     * @return
     */
    public List<Map<String, Object>> getCustFincInfo(QueryModel model){
        PageHelper.startPage(model.getPage(), model.getSize());
        List<Map<String, Object>> fincInfoList = null;
        fincInfoList = custViewMapper.getCustFincInfo(model);
        PageHelper.clearPage();
        return fincInfoList;
    }

    /**
     * 基金明细
     * @param model
     * @return
     */
    public List<Map<String, Object>> getCustFundInfo(QueryModel model){
        PageHelper.startPage(model.getPage(), model.getSize());
        List<Map<String, Object>> fundInfoList = null;
        fundInfoList = custViewMapper.getCustFundInfo(model);
        PageHelper.clearPage();
        return fundInfoList;
    }

    /**
     * 保险明细
     * @param model
     * @return
     */
    public List<Map<String, Object>> getCustBxInfo(QueryModel model){
        PageHelper.startPage(model.getPage(), model.getSize());
        List<Map<String, Object>> bxInfoList = null;
        bxInfoList = custViewMapper.getCustBxInfo(model);
        PageHelper.clearPage();
        return bxInfoList;
    }

    /**
     * 信托明细
     * @param model
     * @return
     */
    public List<Map<String, Object>> getCustXtInfo(QueryModel model){
        PageHelper.startPage(model.getPage(), model.getSize());
        List<Map<String, Object>> xtInfoList = null;
        xtInfoList = custViewMapper.getCustXtInfo(model);
        PageHelper.clearPage();
        return xtInfoList;
    }

    /**
     * 客户持有产品标签列表展示
     * @param model
     * @return
     */
    public List<Map<String, Object>> getCustAllTags(QueryModel model){
        return  custViewMapper.getcustAllTag(model);
    }

    /**
     * 关联信息-家庭关系
     * @param model
     * @return
     */
    public List<Map<String,Object>> getFmyRel(QueryModel model){
        PageHelper.startPage(model.getPage(),model.getSize());
        List<Map<String,Object>> famInfo = null;
        famInfo = custViewMapper.getFmyRel(model);
        PageHelper.clearPage();
        return famInfo;
    }

    /**
     * 关联信息-资金流向
     * @param model
     * @return
     */
    public List<Map<String,Object>> getFndFlow(QueryModel model){
        PageHelper.startPage(model.getPage(),model.getSize());
        List<Map<String,Object>> fnd = null;
        fnd = custViewMapper.getFndFlow(model);
        PageHelper.clearPage();
        return fnd;
    }

    /**
     * 关联信息-担保关系
     * @param model
     * @return
     */
    public List<Map<String,Object>> getGurtRel(QueryModel model){
        PageHelper.startPage(model.getPage(),model.getSize());
        List<Map<String,Object>> gurtInfo = null;
        gurtInfo = custViewMapper.getGurtRel(model);
        PageHelper.clearPage();
        return gurtInfo;
    }

    /**
     * 关联信息-对外投资
     * @param model
     * @return
     */
    public List<Map<String,Object>> getExtIvs(QueryModel model){
        PageHelper.startPage(model.getPage(),model.getSize());
        List<Map<String,Object>> extIvsInfo = null;
        extIvsInfo = custViewMapper.getExtIvs(model);
        PageHelper.clearPage();
        return extIvsInfo;
    }

    /**
     * 当前客户负债信息-环形图展示
     * @return
     */
    public List<Map<String, Object>> getliabilityInfo(QueryModel model){
        return custViewMapper.getCustliabilityInfo(model);
    }

    /**
     * 当前资产时点余额-环形图展示
     * @param model
     * @return
     */
    public List<Map<String, Object>> getCustAssetTime(QueryModel model){
        return custViewMapper.getCustAssetTime(model);
    }

    /**
     * 客户半年资产波动-折线图展示
     * @param model
     * @return
     */
    public List<Map<String, Object>> getAssertsChangeMonthTrend(QueryModel model){
        return custViewMapper.getAssertsChangeMonthTrend(model);
    }

    /**
     * 客户网格归属信息历史
     * @param model
     * @return
     */
    public List<Map<String, Object>> getCustBelongHis(QueryModel model){
        PageHelper.startPage(model.getPage(),model.getSize());
        List<Map<String,Object>> hisInfo = null;
        hisInfo = custViewMapper.custBelongHis(model);
        PageHelper.clearPage();
        return hisInfo;
    }
}
